﻿using System;
using System.Collections.Generic;
using System.Text;
using MapReduce;

namespace MapReduceTest
{
    public class WordCountReduce : IReduce 
    {
        public IEnumerable<KeyValuePair<String, String>> Execute(String pKey, List<String> pValues)
        {
            List<KeyValuePair<String, String>> op = new List<KeyValuePair<String, String>>();

            int wordCount = 0;
            foreach (String strCount in pValues)
            {
                wordCount += int.Parse(strCount);
            }

            op.Add(new KeyValuePair<String, String>(pKey, wordCount.ToString()));
            return op;
        }


    }//Class WordCountReduce
}
/*
        public static IEnumerable<KeyValuePair<String, String>> MyReduceMethod(String pKey, List<String> pValues)
        {

            List<KeyValuePair<String, String>> op = new List<KeyValuePair<String, String>>();

            int wordCount = 0;
            foreach (String strCount in pValues)
            {
                wordCount += int.Parse(strCount);
            }

            op.Add(new KeyValuePair<String, String>(pKey, wordCount.ToString()));
            return op;
        }//ReduceMethod
*/